<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="(item,index) in list">{{item.name}} - {{item.price}} / <input type="text" v-model="item.count"></li>
        </ul>
        {{total}}
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                list:[
                    {
                        name:"西瓜",
                        price:12,
                        count:2
                    },
                    {
                        name:"草莓",
                        price:22,
                        count:10
                    },
                    {
                        name:"火龙果",
                        price:15,
                        count:5
                    }
                ]
            },
            computed:{
                total(){
                    let prices = 0
                    this.list.forEach((item) => {
                        prices += item.price * item.count
                    })
                    return prices
                }
            }
        })
    </script>
</body>
</html>